Skip to content

fix(cdk/overlay): scroll was blocked when zoomed out even if scrolling wasn't an option #30762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

szoboszlaypali
Copy link
Contributor

Fixes that an unnecessary disabled scroll bar was added when zoomed out during opening dialogs.

Fixes #25054.

When you zoom out using the browser (not the style.zoom css), dimensions can become non-whole numbers. window.innerHeight/innerWidth uses Math.floor to round these dimensions, while body.scrollHeight/scrollWidth uses Math.round (at least that's what I assume), so in case you zoom out and your browser shows that your width is 1000.66px for example, the previous implementation returned false positives if there were no scroll bars, as the scrollWidth was 1001px while innerWidth was only 1000.

Another thing I've ran into is using the style.zoom css api, while the innerHeight and innerWidth remains unchanged during zoom, working as intended body.scrollWidth can outgrow window.innerWidth without a scroll bar appearing (easily testable with the Google home page).

Relying on the root documentElement's scrollWidth and scrollHeight seems to fix both cases.

@szoboszlaypali szoboszlaypali requested a review from a team as a code owner April 1, 2025 18:57
@szoboszlaypali szoboszlaypali requested review from andrewseguin and wagnermaciel and removed request for a team April 1, 2025 18:57
@szoboszlaypali
Copy link
Contributor Author

This PR was created after I realized that I merged into my previous changes instead of rebasing, then the revert made it even worse. Previous #30548

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Apr 2, 2025
…g wasn't an option

Fixes that an unnecessary disabled scroll bar was added when zoomed out during opening dialogs.

Fixes angular#25054
@mmalerba mmalerba force-pushed the global-scrollblock-fix branch from fb5ef05 to 394ae27 Compare April 22, 2025 17:45
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Apr 22, 2025
@mmalerba mmalerba merged commit 1dd643e into angular:main Apr 22, 2025
20 of 23 checks passed
@mmalerba
Copy link
Contributor

The changes were merged into the following branches: main, 19.2.x

mmalerba pushed a commit that referenced this pull request Apr 22, 2025
…g wasn't an option (#30762)

Fixes that an unnecessary disabled scroll bar was added when zoomed out during opening dialogs.

Fixes #25054

(cherry picked from commit 1dd643e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: cdk/overlay target: patch This PR is targeted for the next patch release
Projects
None yet
2 participants